<%@page pageEncoding="UTF-8" contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
%>
<html>
	<jsp:include page="../common/init.jsp"  flush="false"></jsp:include>
	<head>
		<title>部门详细信息页面</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<META HTTP-EQUIV="pragma" CONTENT="no-cache">
		<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache,   must-revalidate">
		<META HTTP-EQUIV="expires" CONTENT="0">
        <link rel="stylesheet" href="<%=path%>/css/fixedTable.css" type="text/css" />
        <script type="text/javascript" src="<%=request.getContextPath()%>/dwr/engine.js"></script>        
		<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/interface/BmxxService.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/engine.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/util.js"></script>		
        <script type="text/javascript" src="<%=request.getContextPath()%>/javaScript/jquery.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/javaScript/jquery.fixedheadertable.min.js"></script>
		<script type="text/javascript">	
			 $(document).ready(function(){
				    $('#listTable').fixedHeaderTable({altClass: 'odd', themeClass: 'fancyTable', autoShow: false });
				    $('#listTable').fixedHeaderTable('show');
	         });    
			//数据查询;
			function doSearch(action)
			{
				if(isSpecial(document.getElementById("bmmc").value))
				{
					alert("部门名称包含非法字符,请重新输入!");
					document.getElementById("bmmc").focus();
					return false;
				}
				document.forms[0].action = action;
				document.forms[0].submit();
			}
			
			//添加页面跳转方法
			function doAdd()
			{
				showPage("createBmxxForm.do?sjbmbh=${sjbmbh}",410,480);
			}
			
			//验证部门下是否用人员
			function checkBmry(bmbh)
			{
				var txt = "no";
				DWREngine.setAsync(false);	   
				BmxxService.checkHasPeople(bmbh,function(data){
			       if(data == true){
			             txt = 'yes';
			        }
				});
				DWREngine.setAsync(true);	
				return txt;
			}
			
			//删除方法
			function doDelete(bmbh,bmmc)
			{   
				var action="removeBmxx.do";
				var bmbhs ="";//存放多个部门编号;
				if(bmbh!="")
				{
					bmbhs=bmbh;
				}
				else
				{
					if(checkSCount()<1)
					{
						alert("请选中要删除的记录!");
						return false;
					}
					bmbhs = checksValue();
				}
				var delBmbhs=bmbhs.split(",");
				var errorMes = "";
				if(delBmbhs.length>1)
				{
					for(var i=0;i<delBmbhs.length-1;i++)
					{
						if(checkBmry(delBmbhs[i])=='yes')
						{
							errorMes +=delBmmc[i]+",";
						}
					}
					errorMes=errorMes.substring(0,errorMes.lastIndexOf(","));
				}
				else
				{
						if(checkBmry(delBmbhs[0])=='yes')
						{
							errorMes=bmmc+"";
						}
				}
				document.forms[0].bmbhs.value=bmbhs;
				if(errorMes!="")
				{
					if(confirm(errorMes+"部门下已存在人员信息,确定要删除记录吗?"))
					{
						document.forms[0].action=action;
						document.forms[0].submit();
					}
					else
					{
						return false;
					}
				}
				else if(confirm("确定要删除记录吗?"))
				{
					document.forms[0].action=action;
					document.forms[0].submit();
				}	
				else
				{
					return false;
				}
			}
			
			//排序
			function doPaixu(numSize)
			{
				if(numSize<2)
				{
					alert("下属部门个数少于2个，不需要排序。");
					return false;
				}
				else
				{
					showPage('listOrderBmxx.do?sjbmbh=<s:property  value="sjbmbh"/>',400,400);
				}
			}					
			
			//生成功能按钮	
			mpmenu1=new mMenu('','doAdd()','script','<%=path%>/images/img_ht_wz_37.gif','62','24','0','100','2');
			mpmenu3=new mMenu('','doDelete(\"\",\"\")','script','<%=path%>/images/img_ht_wz_41.gif','62','24','0','20','0');
			mpmenu4=new mMenu('','doSearch(\"listBmxx.do\")','script','<%=path%>/images/img_ht_wz_46.gif','62','24','0','300','0');
			<%if (!(request.getAttribute("orderFlag") + "").equals("-1")) {%>
			mpmenu5=new mMenu('','doPaixu(<s:property value="bmxxList.size"/>)','script','<%=path%>/images/img_ht_wz_80.gif','62','24','0','100','2');
			<%}%>
			<s:if test="urlFlag=='delete'">
			   parent.flleft.location.reload();
			</s:if>
	</script>
	</head>
	
	<body>
		<s:form action="" method="post">
			<table cellspacing="0" cellpadding="0" class="main_tab1">
				<tr>
					<td class="">
						<img src="<%=path%>/images/img_ht_wz_28.gif" alt="left" />
					</td>
					<td class="main_tab1_td2">
						<div id="location">
							部门管理
						</div>
						<div id="funbut">
							<SCRIPT>document.write(mwritetodocument());</SCRIPT>
						</div>
					</td>
					<td class="main_tab1_td1">
						<img src="<%=path%>/images/img_ht_wz_32.gif" alt="right" />
					</td>
				</tr>
				<tr>
					<td colspan="3" class="main_tab1_td3">
						<div id="mainbg">
							<div class="jiange10"></div>
							<table width="100%" border="0" cellspacing="0" cellpadding="0"
								class="main_tab3">
								<tr>
									<th width="100">
										<img src="<%=path%>/images/img_ht_wz_58.gif" alt="查询条件" class="img_01">
										查询条件
									</th>
									<td>
										<table width="100%"  border="0" cellspacing="0" cellpadding="0"
											class="main_tab4">
											<tr>
												<td width="15%" align="right">
													部门名称：
												</td>
												<td width="85%" align="left">
													<input id="bmmc" name="appsysBmxx.bmmc" type="text" class="inp_01" size="20" maxlength="25" value="<s:property value="appsysBmxx.bmmc" />">
													<input type="hidden" name="urlFlag" value="self">
													<input name="sjbmbh" type="hidden" value="<s:property value="sjbmbh" />">
													<input name="bmbhs" type="hidden" value="">
												</td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
							<div class="jiange10"></div>
							<div  style="height: 80%; width: 100%; overflow: auto;">
								<table id="listTable" border="0" cellspacing="0" cellpadding="0">
								  <thead>	
									<tr>
										<th>
											全选 <input type="checkbox" id="ids" name="checkbox3" value="1" onclick="selectAll();">
										</th>
										<th>
											操作
										</th>
										<th>
											部门名称
										</th>
										<th>
											创建人
										</th>
										<th>
											创建日期
										</th>
									</tr>
								   </thead>
								   <tbody>										
									<s:iterator value="bmxxList" status="index">									
										<tr valign="bottom" height="25" ondblclick="showPage('infoBmxx.do?bmbh=<s:property  value="bmbh" />',410,480);">
											<td>
												<input type="checkBox" name="id" onclick="selectNoAll()"
													value="<s:property  value="bmbh" />">
												<input type="hidden" name="delBmmc"
													value="<s:property  value="bmmc" />">
											</td>
											<td>
												<a href="#" onclick="showPage('reworkBmxxForm.do?bmbhs=<s:property  value="bmbh" />',410,480)">修改</a>
												<a href="#" onclick=doDelete("<s:property  value="bmbh" />","<s:property  value="bmmc" />") >删除</a>
											</td>
											<td>											       										
												<s:if test="bmmc.length()>10">
													<s:property value="bmmc.substring(0,10)" />...
			                                    </s:if>
			                                     <s:else>
													<s:property value="bmmc" />
												</s:else> 
											</td>
											<td>
												<s:property value="cjr" />
											</td>
											<td align="center">
												<s:date name="cjrq" format="yyyy-MM-dd" />
											</td>
										</tr>
									</s:iterator>
									</tbody>
								</table>
							</div>
							<jsp:include page="../common/page.jsp">
								<jsp:param value="listBmxx.do" name="listAction" />
							</jsp:include>
						</div>
					</td>
				</tr>
				<tr>
					<td class="main_tab1_td4">
						<img src="<%=path%>/images/img_ht_wz_65.gif" alt="left" />
					</td>
					<td class="main_tab1_td5"></td>
					<td class="main_tab1_td4">
						<img src="<%=path%>/images/img_ht_wz_67.gif" alt="right" />
					</td>
				</tr>
			</table>
		</s:form>
	</body>
</html>
